package com.rong.shop.config;

import com.rong.shop.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 处理拦截器的注册
@Configuration
public class LoginInterceptorConfigurer implements WebMvcConfigurer {

    HandlerInterceptor handlerInterceptor = new LoginInterceptor();

    // 配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(handlerInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/bootstrap3/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/images/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/web/index.html")
                .excludePathPatterns("/web/register.html")
                .excludePathPatterns("/web/login.html")
                .excludePathPatterns("/users/reg")
                .excludePathPatterns("/users/login")
                .excludePathPatterns("/addressDistricts/**")
                .excludePathPatterns("/product/**");

    }


}
